#!/bin/sh
cmd pv %{{
    echo "Processing file: $1" > /dev/stderr  # 调试信息：输出正在处理的文件
    MIME_TYPE=$(file -Lb --mime-type "$1")    # 获取文件的 MIME 类型
    echo "MIME type: $MIME_TYPE" > /dev/stderr  # 调试信息：输出 MIME 类型

    case "$MIME_TYPE" in
        text/*)  bat --paging=never --color=always "$1" ;;
        text/html) lynx -width="$4" -display_charset=utf-8 -dump "$1" ;;
        text/troff) man ./ "$1" | col -b ;;
        image/*) feh "$1" ;;
        application/zip) zipinfo "$1" | less -i ;;
        application/gzip) zless "$1" ;;
        application/*tar|application/*zip*) tar ztvf "$1" | less -i ;;
        audio/*) mpv "$1" ;;
        application/pdf) zathura "$1" ;;
        *) file -b "$1" ;;
    esac
}}
